| QuickBeg.inc - Version 4.2 - 10/05/2006 
| by MacQ with additions by A_Druid_00 
| 
| Copyright 2005-2006 by MacQ all rights reserved. 
| 
| This macro is only authorized for the personal use by members in good standing of the MacroQuest2 VIP forums 
| If you did not pay for VIP access, then you're a cheap, non contributing bastard who sucks the life out of 
| others and will die in hell. 
| 
|------------------------------------------------------------------------------------------------------------ 
| Release Notes: 
| 
| To integrate QuickBeg with your macro do the following: 
| - Add #include QuickBeg.inc to your Include section. 
| - Add /call QuickBegDeclares to your Declaration section. 
| - Add /call MeBegBuff, /call MeBegCure, /call MeBegItem, and /call PetBegBuff wherever you want to beg. 
| - Configure the INI file to meet your needs. 
| 
| The macro uses an INI file called QuickBeg.ini, and assums the INI file is stored in a sub folder called INI, 
| located in your macro folder. If you don't like the INI file being stored in a sub folder, then change the 
| variable qbIniFile below to a new path/name. 
| 
| The INI file is divided into a [GeneralSettings] section and a [CLASS/CHARNAME] section where [CLASS/CHARNAME] 
| is either your character name or your character class depending on how you set the variable groupIniByClass 
| in the [GeneralSettings] section. 
| 
| To utilize cure begging, this macro requires the MQ2Debuffs plugin from PinkFloyd33.  If you don't know how 
| to install/use plugins and/or can't located this plugin, then simply disable cure begging by setting MeBegCure 
| in the INI file to FALSE. 
| 
| ----- INI File Variables - [GeneralSettings] Section ----- 
| 
| - ForceAliasBuild = TRUE/FALSE controls the writing of aliases to your Macroquest.ini file.  If you don't 
|   want to worry about when you need to update your QuickBeg aliases in your Macroquest.ini file, then 
|   leave this set to TRUE.  However, if startup performance is important, then set this to FALSE but remember 
|   to set this to TRUE if/when you change/add aliases in/to your INI file or you get a new Macroquest.ini file. 
|   It is YOUR responsbility to mange this properly and keep YOUR aliases organized, you have been warned. 
| 
| - GroupIniByClass = TRUE/FALSE if this is set to TRUE, then the INI file will be devided into sections by 
|   class type.  If this is set to FALSE, then the INI file will be devided into sections by character name. 
| 
| - SearchRadius = Maximum radius QuickBeg will search for a buffer. 
| 
| - SearchZRadius = Maximum zradius QuickBeg will search for a buffer. 
| 
| - StatusMessages = RUE/FALSE reports QuickBeg settings each time you start. 
| 
|   NOTE: the XX in the variable descriptions below are replaced by a "pseudo array" number (e.g., MeBegBuffName1, 
|   MeBegBuffName2, MeBegBuffName3, etc.) XX should never be a number larger than the appropriate variables 
|   that contain the totals for that particular group of variables (e.g., MeBegBuffTotal, MeBegCureTotal, 
|   MeBegItemTotal, and PetBegBuffTotal). 
| 
| - MeBegBuffTotal = Total number of Buffs QuickBeg could beg. Must be equal to the total number of Buffs in 
|   the MeBegBuff group listed in your INI file. 
| 
| - MeBegBuffNameXX = Contains the Name of the buff you want to beg.  QuickBeg will not beg for this buff if 
|   you are already wearing it or if this buff will NOT stack with another buff you are currently wearing. 
| 
| - MeBegBuffSourceXX = Contains the Class(s) (in three-letter class codes) that can cast the Buff listed in 
|   MeBegBuffNameXX or a substitute Buff from another class that is similar in nature to the Buff listed. List 
|   the Primary Class FIRST and any alternate classes after.  If you set AlternateBeg to TRUE, QuickBeg will look 
|   for alternate (substitute) classes if no Primary class is available.  Seperate each class with a verticle 
|   bar "|", do not start or end with a vertical bar. 
| 
| - MeBegBuffAliasXX = Contains the aliases for Buff(s) you want to beg for YOURSELF.  From inside EQ an alias 
|   controls on/off the begging for this buff. 
| 
| - MeBegBuffLevelXX = QuickBeg will not ask for this particular Buff if the PC is below this level. If you set the 
|   variable MinBegLevel to a number greater than zero, described below, it will superseed MeBegBuffLevelXX. 
| 
| - MeBegCureTotal = Total number of Cures QuickBeg could beg. Must be equal to the total number of Cures in 
|   the MeBegCure group listed in your INI file. 
| 
| - MeBegCureTypeXX = Contains the Type Name of the Curse you received.  This is per the different types of curses 
|   as part of the MQ2Debuffs plugin written by PinkFloyd33.  You will need to reference that plugin to determin 
|   the current types of debuff detection possible. 
| 
| - MeBegCureSourceXX = Contains the Class(s) (in three-letter class codes) that can cast a Cure for the curses 
|   listed in MeBegCureTypeXX or a substitute Cure from another class that is similar in nature to the Cure listed. 
|   List the Primary Class FIRST and any alternate classes after.  If you set AlternateBeg to TRUE, QuickBeg will look 
|   for alternate (substitute) classes if no Primary class is available.  Seperate each class with a verticle 
|   bar "|", do not start or end with a vertical bar. 
| 
| - MeBegCureAliasXX = These variables contain the aliases for Cure you want to beg for YOURSELF.  From inside EQ 
|   an alias controls on/off the begging for this cure. 
| 
| - MeBegCureLevelXX = QuickBeg will not ask for this particular Cure if the PC is below this level. If you set the 
|   variable MinBegLevel to a number greater than zero, described below, it will superseed MeBegCureLevelXX. 
| 
| - MeBegItemTotal = Total number of Items QuickBeg could beg. Must be equal to the total number of Items in 
|   the MeBegItem group listed in your INI file. 
| 
| - MeBegItemNameXX = Contains the Name(s) of the Item(s) you want to beg.  QuickBeg will not beg for this Item if 
|   you already have it in your inventory or on your cursor.  Seperate each item with a verticle bar '|', do not start 
|   or end with a verticle bar. 
| 
| - MeBegItemSourceXX = Contains the Class(s) (in three-letter class codes) that can cast this Item listed in 
|   MeBegItemNameXX or a substitute Item from another class that is similar in nature to the Item listed. 
|   List the Primary Class FIRST and any alternate classes after.  If you set AlternateBeg to TRUE, QuickBeg will look 
|   for alternate (substitute) classes if no Primary class is available.  Seperate each class with a verticle 
|   bar "|", do not start or end with a vertical bar. 
| 
| - MeBegItemAliasXX = Contains the aliases for Item(s) you want to beg for YOURSELF.  From inside EQ an alias controls 
|   (on/off) for begging this item. 
| 
| - MeBegItemLevelXX = QuickBeg will not ask for this particular Item if the PC is below this level. If you set the 
|   variable MinBegLevel to a number greater than zero, described below, it will superseed MeBegItemLevelXX. 
| 
| - PetBegBuffTotal = Total number of Pet Buffs QuickBeg could beg. Must be equal to the total number of Pet Buffs in 
|   the petBegBuff group listed in your INI file. 
| 
| - PetBegBuffNameXX = Contains the Name of the Buff you want to beg for YOUR PET.  QuickBeg will not beg for this 
|   buff if your pet is already wearing it or if this buff will not stack with another buff your pet is currently wearing. 
| 
| - PetBegBuffSourceXX = Contains the Class(s) (in three-letter class codes) that can cast the Pet Buff listed in 
|   PetBegBuffNameXX or a substitute Pet Buff from another class that is similar in nature to the Pet Buff listed. List 
|   the Primary Class FIRST and any alternate classes after.  If you set AlternateBeg to TRUE, QuickBeg will look 
|   for alternate (substitute) classes if no Primary class is available.  Seperate each class with a verticle 
|   bar "|", do not start or end with a vertical bar. 
| 
| - PetBegBuffAliasXX = Contains the aliases for Buff(s) you want to beg for YOUR PET.  From inside EQ an alias controls 
|   (on/off) begging for this pet buff. 
| 
| - PetBegBuffLevelXX = QuickBeg will not ask for this particular Pet Buff if the PC is below this level. If you set the 
|   variable MinBegLevel to a number greater than zero, described below, it will superseed PetBegBuffLevelXX. 
| 
|   ----- Variables in INI - [CLASS/NAME] Section ----- 
| 
| - AllowAltBeg = TRUE/FALSE if you defined more than one class in meBegBuffSourceXX, meBegCureSourceXX, meBegItemSourceXX, 
|   or petBegBuffSourceXX, then if QuickBeg can't find the Primary Source (e.g., the FIRST CLASS LISTED) QuickBeg will look 
|   for other class sources you listed (Alternate Sources). For example, you first would probably look for a Magician to 
|   cast a damage shield but not finding one, you might look for a Druid; so you would list MAG|DRU.  Alias is /allowaltbeg 
| 
| - AskAnyone = TRUE/FALSE if set TRUE will ask anyone for buffs regardless if they are in your raid, group, or 
|   guild.  If you set this variable FALSE, QuickBeg will only check first for a raid member in range, 
|   then a group member in range, then a guild member in range. Alias is /askanyone 
| 
| - AskDelay = int variable containing the delay (in DECI-SECONDS) between sending the same buff request. This also 
|   means if you asked for a buff, received the buff then its dispelled or you click it off, QuickBeg will still 
|   wait the time specified in askDelay before asking again.  Alias is /askdelay 
| 
| - BegChannel = channel you will beg for buffs (e.g., tell, say, group, etc.) Six valid choices are: tell,t,i msg,g,say,i say 
|   Alias is /begchannel. 
| 
| - BegIfInvis = TRUE/FALSE will or will not beg if you are invised. Alias is /begifinvis. 
| 
| - MeBegBuff = TRUE/FALSE master on/off for personal buff begging.  Alias is /mebegbuff. 
| 
| - MeBegCure = TRUE/FALSE master on/off for personal cure begging. Alias is /mebegcure. 
| 
| - MeBegItem = TRUE/FALSE master on/off for personal item begging. Alias is /mebegitem. 
| 
| - PetBegBuff = TRUE/FALSE master on/off for pet buff begging. Alias is /petbegbuff. 
| 
| - MinBegLevel = If this variable is set to a positive number, you will not ask for buffs from anyone below this 
|   level.  However, if this variable is set to zero, QuickBeg will use individual spell specific level 
|   checks (e.g., MeBegBuffLevelXX, MeBegCureLevelXX, MeBegItemLevelXX, PetBegBuffLevelXX). Alias is /minbeglvl. 
| 
| - MeBegBuffStatusXX = TRUE/FALSE flag controlling Buff begging for the each personal buff. 
| 
| - MeBegBuffMessageXX = The message you want to send when you ask for this Buff. 
| 
| - MeBegCureStatusXX = TRUE/FALSE flag controlling Cure begging for the each debuff type. 
| 
| - MeBegCureMessageXX = The message you want to send when you ask for this Cure. 
| 
| - MeBegItemStatusXX = TRUE/FALSE flag controlling begging for an Item (like a mod rod) not in your inventory or 
|   on your cursor.  If QuickBeg finds the item in your inventory or on your cursor, it will NOT beg for it. 
| 
| - MeBegItemMessageXX = The message you want to send when you ask for this Item. 
| 
| - PetBegBuffStatusXX = TRUE/FALSE flag controlling Pet Buff begging for the buff. 
| 
| - PetBegBuffPetssageXX = The message you want to send when you ask for this Pet Buff. 
| 
| You can change several settings while the macro is running by typing an alias.  To use an alias, from an EQ command 
| line, type /XXX YYY (assuming there is an alias) where XXX is the alias name and YYY is the new value.  You don't 
| need to put quotes around the XXX value even if it has spaces. 
| 
| Example: 
| /askdelay 900 -- sets a the ask delay to 90 seconds. 
| /chatchannel i msg -- sets chat channel to "i msg". 
| 
| For changing Boolean variables you have a few choices.  You can type an alias, if you defined one in the INI file, 
| not followed by a new parameter and QuickBeg will simply toggle off (FALSE) if its ON, or ON (TRUE) if its OFF. You 
| can also pass a variety of parameters: 1, 0, TRUE, FALSE, ON, or OFF. 
| 
| Example- Assuming you defined an alias called /begsow, which in this example might control begging for Spirit of 
| the Wolf, here are your options: 
| /begsow on -- turns Oak begging on. 
| /begsow off --  turns Oak begging off. 
| /begsow TRUE -- turns Oak begging on. 
| /begsow FALSE -- turns Oak begging off. 
| /begsow -- turns OFF if its currently ON, or turns ON if its currently OFF (toggle style). 
|------------------------------------------------------------------------------------------------------------ 
| 
#event QBSetVar "[MQ2] QBSetVar:#*#" 

Sub QuickBegDeclares 
   /declare meBegBuffCounter     int      outer 1 
   /declare meBegCureCounter     int      outer 1 
   /declare meBegItemCounter     int      outer 1 
   /declare petBegBuffCounter    int      outer 1 
   /declare spamDelayTimer       timer    outer 
   /declare qbIniFile            string   outer ./INI/QuickBeg.ini 
   /declare i                    int      local 

   /call QBDeclareIniVar forceAliasBuild  bool     GeneralSettings TRUE 
   /if ( ${forceAliasBuild} ) { 
      /echo QuickBeg writing aliases to your Macroquest.ini file. 
      /echo You can disbale this by setting forceAliasBuild to FALSE in your ${qbIniFile} file. 
   } 

   /call QBDeclareIniVar groupIniByClass  bool     GeneralSettings FALSE 
   /call QBDeclareIniVar petNameSuffix    bool     GeneralSettings TRUE 
   /call QBDeclareIniVar searchRadius     int      GeneralSettings 100 
   /call QBDeclareIniVar searchZRadius    int      GeneralSettings 100 
   /call QBDeclareIniVar statusMessages   bool     GeneralSettings FALSE 

   /call QBDeclareIniVar allowAltBeg      bool     ${If[${groupIniByClass},${Me.Class.ShortName},${Me.CleanName}]} FALSE /allowaltbeg 
   /call QBDeclareIniVar askDelay         int      ${If[${groupIniByClass},${Me.Class.ShortName},${Me.CleanName}]} 1800  /askdelay 
   /call QBDeclareIniVar askAnyone        bool     ${If[${groupIniByClass},${Me.Class.ShortName},${Me.CleanName}]} FALSE /askanyone 
   /call QBDeclareIniVar begChannel       string   ${If[${groupIniByClass},${Me.Class.ShortName},${Me.CleanName}]} tell  /begchannel 
   /call QBDeclareIniVar begIfInvis       bool     ${If[${groupIniByClass},${Me.Class.ShortName},${Me.CleanName}]} FALSE /begifinvis 
   /call QBDeclareIniVar meBegBuff        bool     ${If[${groupIniByClass},${Me.Class.ShortName},${Me.CleanName}]} FALSE /mebegbuff 
   /call QBDeclareIniVar meBegItem        bool     ${If[${groupIniByClass},${Me.Class.ShortName},${Me.CleanName}]} FALSE /mebegitem 
   /call QBDeclareIniVar meBegCure        bool     ${If[${groupIniByClass},${Me.Class.ShortName},${Me.CleanName}]} FALSE /mebegcure 
   /call QBDeclareIniVar petBegBuff       bool     ${If[${groupIniByClass},${Me.Class.ShortName},${Me.CleanName}]} FALSE /petbegbuff 
   /call QBDeclareIniVar minBegLevel      int      ${If[${groupIniByClass},${Me.Class.ShortName},${Me.CleanName}]} 0     /minbeglevel 

   /call QBDeclareIniVar meBegBuffTotal               int      GeneralSettings 1 
   /if ( ${meBegBuffTotal} ) { 
      /for i 1 to ${meBegBuffTotal} 
         /declare meBegBuffTimer${i}                  timer  outer 
         /call QBDeclareIniVar meBegBuffName${i}      string GeneralSettings "REPLACE WITH SINGLE BUFF NAME" 
         /call QBDeclareIniVar meBegBuffSource${i}    string GeneralSettings "REPLACE WITH BUFFING PC CLASS(S) SEPERATED BY VERTICLE BAR '|' IF MORE THAN ONE CLASS" 
         /if ( ${minBegLevel} ) { 
            /declare meBegBuffLevel${i}               int outer ${minBegLevel} 
         } else { 
            /call QBDeclareIniVar meBegBuffLevel${i}  int    GeneralSettings 
         } 
         /call QBDeclareIniVar meBegBuffStatus${i}    bool   ${If[${groupIniByClass},${Me.Class.ShortName},${Me.CleanName}]} FALSE 
         /call QBDeclareIniVar meBegBuffMessage${i}   string ${If[${groupIniByClass},${Me.Class.ShortName},${Me.CleanName}]} "REPLACE WITH BEG BUFF MESSAGE" 
         /if ( ${forceAliasBuild} ) /call QBAliasIniVar meBegBuffAlias${i} GeneralSettings meBegBuffStatus${i} 
      /next i 
   } 

   /call QBDeclareIniVar meBegCureTotal               int    GeneralSettings 1 
   /if ( ${meBegCureTotal} ) { 
      /for i 1 to ${meBegCureTotal} 
         /declare meBegCureTimer${i}                  timer  outer 
         /call QBDeclareIniVar meBegCureType${i}      string GeneralSettings "REPLACE WITH SINGLE CURSE NAME (per MQ2Debuffs plugin)" 
         /call QBDeclareIniVar meBegCureSource${i}    string GeneralSettings "REPLACE WITH CURING PC CLASS(S) SEPERATED BY VERTICLE BAR '|' IF MORE THAN ONE CLASS" 
         /if ( ${minBegLevel} ) { 
            /declare meBegCureLevel${i}               int outer ${minBegLevel} 
         } else { 
            /call QBDeclareIniVar meBegCureLevel${i}  int GeneralSettings 
         } 
         /call QBDeclareIniVar meBegCureStatus${i}    bool ${If[${groupIniByClass},${Me.Class.ShortName},${Me.CleanName}]} FALSE 
         /call QBDeclareIniVar meBegCureMessage${i}   string ${If[${groupIniByClass},${Me.Class.ShortName},${Me.CleanName}]} "REPLACE WITH BEG CURE MESSAGE" 
         /if ( ${forceAliasBuild} ) /call QBAliasIniVar meBegCureAlias${i} GeneralSettings meBegCureStatus${i} 
      /next i 
   } 

   /call QBDeclareIniVar meBegItemTotal               int      GeneralSettings 1 
   /if ( ${meBegItemTotal} ) { 
      /for i 1 to ${meBegItemTotal} 
         /declare meBegItemTimer${i}                  timer outer 
         /call QBDeclareIniVar meBegItemName${i}      string GeneralSettings "REPLACE WITH ITEM NAMES(S) SEPERATED BY VERTICLE BAR '|' IF MORE THAN ONE ITEM" 
         /call QBDeclareIniVar meBegItemSource${i}    string GeneralSettings "REPLACE WITH SUMMONING PC CLASS(S) SEPERATED BY VERTICLE BAR '|' IF MORE THAN ONE CLASS" 
         /if ( ${minBegLevel} ) { 
            /declare meBegItemLevel${i}               int outer ${minBegLevel} 
         } else { 
            /call QBDeclareIniVar meBegItemLevel${i}  int    GeneralSettings 
         } 
         /call QBDeclareIniVar meBegItemStatus${i}    bool   ${If[${groupIniByClass},${Me.Class.ShortName},${Me.CleanName}]} FALSE 
         /call QBDeclareIniVar meBegItemMessage${i}   string ${If[${groupIniByClass},${Me.Class.ShortName},${Me.CleanName}]} "REPLACE WITH BEG ITEM MESSAGE" 
         /if ( ${forceAliasBuild} ) /call QBAliasIniVar meBegItemAlias${i} GeneralSettings meBegItemStatus${i} 
      /next i 
   } 

   /call QBDeclareIniVar petBegBuffTotal              int      GeneralSettings 1 
   /if ( ${petBegBuffTotal} ) { 
      /for i 1 to ${petBegBuffTotal} 
         /declare petBegBuffTimer${i}                 timer outer 
         /call QBDeclareIniVar petBegBuffName${i}     string GeneralSettings "REPLACE WITH SINGLE PET BUFF NAME" 
         /call QBDeclareIniVar petBegBuffSource${i}   string GeneralSettingS "REPLACE WITH BUFFING PC CLASS(S) SEPERATED BY VERTICLE BAR '|' IF MORE THAN ONE CLASS" 
         /if ( ${minBegLevel} ) { 
            /declare petBegBuffLevel${i}              int outer ${minBegLevel} 
         } else { 
            /call QBDeclareIniVar petBegBuffLevel${i} int    GeneralSettings 
         } 
         /call QBDeclareIniVar petBegBuffStatus${i}   bool   ${If[${groupIniByClass},${Me.Class.ShortName},${Me.CleanName}]} FALSE 
         /call QBDeclareIniVar petBegBuffMessage${i}  string ${If[${groupIniByClass},${Me.Class.ShortName},${Me.CleanName}]} "REPLACE WITH PET BEG BUFF MESSAGE" 
         /if ( ${forceAliasBuild} ) /call QBAliasIniVar petBegBuffAlias${i} GeneralSettings petBegBuffStatus${i} 
      /next i 
   } 

   /if ( ${statusMessages} ) { 
      /if ( !${meBegBuff} ) { 
         /echo QuickBeg will NOT beg for My Buffs. 
      } else { 
         /echo QuickBeg will beg for My Buffs. 
      } 
      /if ( !${meBegCure} ) { 
         /echo QuickBeg will NOT beg for My Cures. 
      } else { 
         /echo QuickBeg will beg for My Cures. 
      } 
      /if ( !${meBegItem} ) { 
         /echo QuickBeg will NOT beg for My Items. 
      } else { 
         /echo QuickBeg will beg for My Items. 
      } 
      /if ( !${petBegBuff} ) { 
         /echo QuickBeg will NOT beg for Pet Buffs. 
      } else { 
         /echo QuickBeg will beg for Pet Buffs. 
      } 
      /if ( ${meBegBuff} || ${meBegCure} || ${meBegItem} || ${petBegBuff} ) { 
         /if ( ${askAnyone} ) { 
            /echo QuickBeg will beg from anyone in Range. 
         } else { 
               /echo QuickBeg will only beg from Raid/Group/Guild members in Range. 
         } 
         /if ( ${allowAltBeg} ) { 
            /echo QuickBeg will beg from Alternate sources. 
         } else { 
            /echo QuickBeg will NOT beg from Alternate sources. 
         } 
         /echo QuickBeg will wait ${Int[${Math.Calc[${askDelay}/10]}]} seconds between requests for the same buff. 
         /echo QuickBeg will beg in channel: /${begChannel} 
         /if ( ${BegIfMeInvis} ) { 
            /echo QuickBeg will beg for buffs if I am invised. 
         } else { 
            /echo QuickBeg will NOT beg for buffs if I am invised. 
         } 
      } 
   } 
/return 

Sub MeBegBuff 
   /if ( ${spamDelayTimer} || !${meBegBuffTotal} || !${meBegBuff} || !${Me.FreeBuffSlots} || ( ${Me.Invis} && !${begIfInvis} ) ) /return 
   /declare i int local 
   /declare j int local 
   /for i ${meBegBuffCounter} to ${meBegBuffTotal} 
      /if ( ${meBegBuffStatus${i}} && !${meBegBuffTimer${i}} && ${Spell[${meBegBuffName${i}}].Stacks} ) { 
         /for j 1 to ${Math.Calc[${meBegBuffSource${i}.Count[|]}+1]} 
            /call FindBuffer "${meBegBuffMessage${i}}" ${meBegBuffSource${i}.Arg[${j},|]} meBegBuffTimer${i} ${meBegBuffLevel${i}} 
            /if ( ${Macro.Return.Equal[BEG_SUCCESS]} ) { 
               /call IncrementCounter "meBegBuffCounter" "meBegBuffTotal" 
               /return 
            } 
         /if ( ${allowAltBeg} ) /next j 
      } 
   /call IncrementCounter "meBegBuffCounter" "meBegBuffTotal" 
   /next i 
/return 

Sub MeBegCure 
   /if ( ${spamDelayTimer} || !${meBegCureTotal} || !${meBegCure} || ( ${Me.Invis} && !${begIfInvis} ) ) /return 
   /declare i int local 
   /declare j int local 
   /for i ${meBegCureCounter} to ${meBegCureTotal} 
      /if ( ${meBegCureStatus${i}} && !${meBegCureTimer${i}} && ${Debuff.${meBegCureType${i}}} ) { 
         /for j 1 to ${Math.Calc[${meBegCureSource${i}.Count[|]}+1]} 
            /call FindBuffer "${meBegCureMessage${i}}" ${meBegCureSource${i}.Arg[${j},|]} meBegCureTimer${i} ${meBegCureLevel${i}} 
            /if ( ${Macro.Return.Equal[BEG_SUCCESS]} ) { 
               /call IncrementCounter "meBegCureCounter" "meBegCureTotal" 
               /return 
            } 
         /if ( ${allowAltBeg} ) /next j 
      } 
   /call IncrementCounter "meBegCureCounter" "meBegCureTotal" 
   /next i 
/return 

Sub MeBegItem 
   /if ( ${spamDelayTimer} || !${meBegItemTotal} || !${meBegItem} || ( ${Me.Invis} && !${begIfInvis} ) ) /return 
   /declare i int local 
   /declare j int local 
   /for i ${meBegItemCounter} to ${meBegItemTotal} 
      /for j 1 to ${Math.Calc[${meBegItemSource${i}.Count[|]}+1]} 
         /if ( ${meBegItemStatus${i}} && !${meBegItemTimer${i}} && !${FindItem[${meBegItemName${i}.Arg[${j},|]}].ID} && !${Cursor.Name.Equal[${meBegItemName${i}.Arg[${j},|]}]} ) { 
            /call FindBuffer "${meBegItemMessage${i}}" ${meBegItemSource${i}.Arg[${j},|]} meBegItemTimer${i} ${meBegItemLevel${i}} 
            /if ( ${Macro.Return.Equal[BEG_SUCCESS]} ) { 
               /call IncrementCounter "meBegItemCounter" "meBegItemTotal" 
               /return 
            } 
         } 
      /if ( ${allowAltBeg} ) /next j 
      /call IncrementCounter "meBegItemCounter" "meBegItemTotal" 
   /next i 
/return 

Sub PetBegBuff 
   /if ( ${spamDelayTimer} || !${Me.Pet.ID} || !${petBegBuffTotal} || !${petBegBuff} || ( ${Me.Invis} && !${begIfInvis} ) ) /return 
   /declare i int local 
   /declare j int local 
   /for i ${petBegBuffCounter} to ${petBegBuffTotal} 
      /if (${petBegBuffStatus${i}} && !${petBegBuffTimer${i}} && ${Spell[${petBegBuffName${i}}].StacksPet} ) { 
         /for j 1 to ${Math.Calc[${petBegBuffSource${i}.Count[|]}+1]} 
            /call FindBuffer "${petBegBuffMessage${i}} ${Me.Pet.CleanName}" ${petBegBuffSource${i}.Arg[${j},|]} petBegBuffTimer${i} 
            /if (${Macro.Return.Equal[BEG_SUCCESS]}) { 
               /call IncrementCounter "petBegBuffCounter" "petBegBuffTotal" 
               /return 
            } 
         /if ( ${allowAltBeg} ) /next j 
      } 
   /call IncrementCounter "petBegBuffCounter" "petBegBuffTotal" 
   /next i 
/return 

Sub FindBuffer(string BegBuff, string BegClass, string BegTimer, int MinBufferLevel) 
   /if ( ${Me.Class.ShortName.Equal[${BegClass}]} )  /return BEG_SUCCESS 
   /if ( ${NearestSpawn[pc group ${BegClass} range ${MinBufferLevel} 100 radius ${searchRadius} zradius ${searchZRadius}].ID} ) /call BegForBuff "${BegBuff}" ${NearestSpawn[PC group ${BegClass} range ${MinBufferLevel} 100]} ${BegTimer} 
   /if ( ${Macro.Return.NotEqual[BEG_SUCCESS]} && ${NearestSpawn[pc raid ${BegClass} range ${MinBufferLevel} 100 radius ${searchRadius} zradius ${searchZRadius}].ID} ) /call BegForBuff "${BegBuff}" ${NearestSpawn[PC raid ${BegClass} range ${MinBufferLevel} 100]} ${BegTimer} 
   /if ( ${Macro.Return.NotEqual[BEG_SUCCESS]} && ${NearestSpawn[pc guild ${BegClass} range ${MinBufferLevel} 100 radius ${searchRadius} zradius ${searchZRadius}].ID} && ${Me.Guild.NotEqual[NULL]} ) /call BegForBuff "${BegBuff}" ${NearestSpawn[PC guild ${BegClass} range ${MinBufferLevel} 100]} ${BegTimer} 
   /if ( ${Macro.Return.NotEqual[BEG_SUCCESS]} && ${askAnyone} && ${NearestSpawn[pc ${BegClass} range ${MinBufferLevel} 100 radius ${searchRadius} zradius ${searchZRadius}].ID} ) /call BegForBuff "${BegBuff}" ${NearestSpawn[PC ${BegClass} range ${MinBufferLevel} 100]} ${BegTimer} 
/return ${Macro.Return} 

Sub BegForBuff(string BegBuff, string BufferName, sring BegTimer) 
   /if ( ${begChannel.Equal[tell]} || ${begChannel.Equal[t]} || ${begChannel.Equal[i msg]} ) { 
      /docommand /${begChannel} ${BufferName} ${BegBuff} 
      /varset ${BegTimer} ${askDelay} 
      /varset spamDelayTimer 3s 
      /return BEG_SUCCESS 
   } else { 
      /if ( ${begChannel.Equal[g]} || ${begChannel.Equal[say]} || ${begChannel.Equal[i say]} ) { 
      /docommand /${begChannel} ${BegBuff} 
      /varset ${BegTimer} ${askDelay} 
      /varset spamDelayTimer 3s 
      /return BEG_SUCCESS 
   } 
/return BEG_FAILED 

Sub IncrementCounter(string BegVarCounterName, string BegVarTotalName) 
   /if ( ${${BegVarCounterName}}==${${BegVarTotalName}} ) { 
      /varset ${BegVarCounterName} 1 
   } else { 
      /varcalc ${BegVarCounterName} ${${BegVarCounterName}}+1 
   } 
/return 

Sub QBDeclareIniVar(string varName, string varType, string sectionName, string varValue, string alias) 
   /if ( !${Defined[${varName}]} ) /declare ${varName} ${varType} outer 
   /declare tempString string local ${Ini[${qbIniFile},${sectionName},${varName},NOTFOUND]} 
   /if ( ${tempString.Equal[NOTFOUND]} ) { 
      /varset ${varName} ${varValue} 
      /ini "${qbIniFile}" "${sectionName}" "${varName}" "${${varName}}" 
   } else { 
      /varset ${varName} ${tempString} 
   } 
   /if ( ${forceAliasBuild} && ${Defined[alias]} ) /squelch /alias ${alias} /echo QBSetVar: ${varName} 
   } 
/return 

Sub QBAliasIniVar(string varName, string sectionName, string aliasVar) 
   /declare tempString string local ${Ini[${qbIniFile},${sectionName},${varName},NOTFOUND]} 
   /if ( ${tempString.NotEqual[NOTFOUND]} && ${forceAliasBuild} ) /squelch /alias ${tempString} /echo QBSetVar: ${aliasVar} 
/return 

Sub Event_QBSetVar(string Line) 
   /declare varName  string local ${Line.Arg[3]} 
   /declare newValue string local ${Line.Arg[4]} 
   /if ( !${Defined[${varName}]} ) /return 
   /if ( ${${varName}(type).Name.Equal[bool]} && ${newValue.Equal[NULL]} ) { 
      /if ( ${${varName}} ) { 
         /varset ${varName} FALSE 
         /echo ${varName} is now OFF 
      } else { 
         /varset ${varName} TRUE 
         /echo ${varName} is now ON 
      } 
   } else { 
      /if ( ${${varName}(type).Name.Equal[bool]} ) { 
         /if ( ${newValue.Equal[on]} || ${newValue.Equal[1]} || ${newValue.Equal[true]} ) { 
         /varset ${varName} TRUE 
         } else { 
            /if ( ${newValue.Equal[off]} || ${newValue.Equal[0]} || ${newValue.Equal[false]} ) { 
            /varset ${varName} FALSE 
            } else { 
               /echo ${varName} was NOT changed 
            } 
         } 
      } else { 
         /if ( !${newValue.Equal[NULL]} ) { 
            /varset ${varName} ${newValue} 
            /echo ${varName} is now ${${varName}} 
         } else { 
            /echo ${varName} was NOT changed 
         } 
      } 
   } 
   /if ( ${groupIniByClass} ) { 
      /ini "${qbIniFile}" "${Me.Class.ShortName}" "${varName}" "${${varName}}" 
   } else { 
      /ini "${qbIniFile}" "${Me.CleanName}" "${varName}" "${${varName}}" 
   } 
/return